home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2 Examples.sit
/
Raven 1.2 Examples
/
Quill
/
Source
/
DialogBoxProxy.cpp
< prev
next >
Wrap
Text File
|
1997-09-08
|
6KB
|
246 lines
/*
* File: DialogBoxProxy.cpp
* Summary: A stand in for TDialogBox that behaves better when it's being edited.
* Written by: Jesse Jones
*
* Copyright ゥ 1996 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <1> 9/02/96 JDJ Created
*/
#include "DialogBoxProxy.h"
#include <List.h>
#include <ZAttribute.h>
#include <ZStream.h>
#include <ZStringUtils.h>
#include "Document.h"
#include "ViewContainer.h"
#include "WindowProxy.h"
// ===================================================================================
// class CDialogBoxProxy
// ===================================================================================
static TReanimatorRegister<CDialogBoxProxy> sDialogProxyRegistrar;
static TReanimatorRegister<CDialogBoxProxy> sDialogBoxRegistrar("TDialogBox");
//---------------------------------------------------------------
//
// CDialogBoxProxy::~CDialogBoxProxy
//
//---------------------------------------------------------------
CDialogBoxProxy::~CDialogBoxProxy()
{
// Delete the view container while we're still the right type.
this->DoDeleteSubPanes();
}
//---------------------------------------------------------------
//
// CDialogBoxProxy::CDialogBoxProxy ()
//
//---------------------------------------------------------------
CDialogBoxProxy::CDialogBoxProxy()
{
this->AddAttribute("Editing", new TAttribute(kNonPersistant));
CWindowProxy::msUseProxy = false;
}
//---------------------------------------------------------------
//
// CDialogBoxProxy::CDialogBoxProxy (SDialogBoxInfo, MCommander*)
//
//---------------------------------------------------------------
CDialogBoxProxy::CDialogBoxProxy(const SDialogBoxInfo& info, MCommander* superCommander) : TDialogBox(info, superCommander)
{
mOldAttributes = mAttributes;
mAttributes.hasCloseBox = true;
mAttributes.resizable = true;
mAttributes.clickThrough = true;
mAttributes.eraseOnUpdate = false;
mAttributes.layer = kRegularLayer;
this->SetDefaultButton(LoadAppString("OK"));
this->SetCancelButton(LoadAppString("Cancel"));
this->AddAttribute("Editing", new TAttribute(kNonPersistant));
CWindowProxy::msUseProxy = false;
}
//---------------------------------------------------------------
//
// CDialogBoxProxy::Create [static]
//
//---------------------------------------------------------------
MReanimatable* CDialogBoxProxy::Create(MReanimatable*)
{
if (CWindowProxy::msUseProxy)
return new CDialogBoxProxy;
else
return new TDialogBox;
}
//---------------------------------------------------------------
//
// CDialogBoxProxy::HandleClick
//
//---------------------------------------------------------------
void CDialogBoxProxy::HandleClick(const TMouseEvent& globalEvent, short partCode)
{
TRect sizeBox = mWindowPtr->portRect;
sizeBox.left = sizeBox.right - 15;
sizeBox.top = sizeBox.bottom - 15;
TPoint localPt = this->PortToLocal(this->GlobalToPort(globalEvent.GetPosition()));
if (sizeBox.Contains(localPt))
partCode = inGrow;
Inherited::HandleClick(globalEvent, partCode);
}
//---------------------------------------------------------------
//
// CDialogBoxProxy::SetInfo
//
//---------------------------------------------------------------
void CDialogBoxProxy::SetInfo(const SWindowInfo& info)
{
Inherited::SetInfo(info);
mOldAttributes = mAttributes;
mAttributes.hasCloseBox = true;
mAttributes.resizable = true;
mAttributes.clickThrough = true;
mAttributes.eraseOnUpdate = false;
mAttributes.layer = kRegularLayer;
}
#pragma mark ハ
//---------------------------------------------------------------
//
// CDialogBoxProxy::Invariant
//
//---------------------------------------------------------------
void CDialogBoxProxy::Invariant() const
{
Inherited::Invariant();
if (mSubPanes->size() > 0) {
ASSERT(mSubPanes->size() == 1);
TPane* subPane = mSubPanes->front();
ASSERT(subPane != nil);
ASSERT(dynamic_cast<CViewContainer*>(subPane) != nil);
}
}
//---------------------------------------------------------------
//
// CDialogBoxProxy::OnStreamOut
//
//---------------------------------------------------------------
void CDialogBoxProxy::OnStreamOut(TOutStream& stream) const
{
CDialogBoxProxy* thisPtr = const_cast<CDialogBoxProxy*>(this);
thisPtr->mAttributes = mOldAttributes;
try {
Inherited::OnStreamOut(stream);
thisPtr->mAttributes.hasCloseBox = true;
thisPtr->mAttributes.resizable = true;
thisPtr->mAttributes.clickThrough = true;
thisPtr->mAttributes.eraseOnUpdate = false;
thisPtr->mAttributes.layer = kRegularLayer;
} catch (...) {
thisPtr->mAttributes.hasCloseBox = true;
thisPtr->mAttributes.resizable = true;
thisPtr->mAttributes.clickThrough = true;
thisPtr->mAttributes.eraseOnUpdate = false;
thisPtr->mAttributes.layer = kRegularLayer;
throw;
}
}
//---------------------------------------------------------------
//
// CDialogBoxProxy::OnReanimated
//
//---------------------------------------------------------------
void CDialogBoxProxy::OnReanimated()
{
Inherited::OnReanimated();
mOldAttributes = mAttributes;
mAttributes.hasCloseBox = true;
mAttributes.resizable = true;
mAttributes.clickThrough = true;
mAttributes.eraseOnUpdate = false;
mAttributes.layer = kRegularLayer;
TDesktop::Instance()->NormalizeWindowOrder();
}
//---------------------------------------------------------------
//
// CDialogBoxProxy::OnOpen
//
//---------------------------------------------------------------
void CDialogBoxProxy::OnOpen()
{
Inherited::OnOpen();
this->Show();
}
//---------------------------------------------------------------
//
// CDialogBoxProxy::DoClickInGrow
//
//---------------------------------------------------------------
void CDialogBoxProxy::DoClickInGrow(const TMouseEvent& globalEvent)
{
TSize oldSize = this->GetSize();
Inherited::DoClickInGrow(globalEvent);
TSize newSize = this->GetSize();
if (newSize != oldSize) {
CViewContainer* container = dynamic_cast<CViewContainer*>(mSubPanes->front());
container->UpdateResource();
}
}